sizegroup: Use _gtk_widget_compute_size_for_orientation()
authorBenjamin Otte <otte@redhat.com>
Sat, 3 Nov 2012 17:57:50 +0000 (18:57 +0100)
committerBenjamin Otte <otte@redhat.com>
Sun, 4 Nov 2012 14:28:43 +0000 (15:28 +0100)
With this function now available, we can do size computation in 2
ways:
(1) Compute size with size groups
(2) Compute size without size groups

And have (1) use (2) instead of setting flags on widgets. This patch
does exactly that.

gtk/gtksizegroup.c
gtk/gtkwidget.c
gtk/gtkwidgetprivate.h

index b9e2ac36a36b18b726b75feabb8660f9fa9fbc38..d1295d0727b2d58f0437663b2124c6f69bb5c344 100644 (file)
@@ -627,17 +627,36 @@ gtk_size_group_get_widgets (GtkSizeGroup *size_group)
   return size_group->priv->widgets;
 }
 
-static void
-compute_dimension (GtkWidget        *widget,
-                  GtkSizeGroupMode  mode,
-                   gint              for_size,
-                  gint             *minimum, /* in-out */
-                  gint             *natural) /* in-out */
+/**
+ * _gtk_size_group_bump_requisition:
+ * @widget: a #GtkWidget
+ * @mode: either %GTK_SIZE_GROUP_HORIZONTAL or %GTK_SIZE_GROUP_VERTICAL, depending
+ *        on the dimension in which to bump the size.
+ * @for_size: Size to request minimum and natural size for
+ * @minimum: a pointer to the widget's minimum size
+ * @natural: a pointer to the widget's natural size
+ *
+ * Refreshes the sizegroup while returning the groups requested
+ * value in the dimension @mode.
+ *
+ * This function is used both to update sizegroup minimum and natural size 
+ * information and widget minimum and natural sizes in multiple passes from 
+ * the size request apis.
+ */
+void
+_gtk_size_group_bump_requisition (GtkWidget        *widget,
+                                 GtkSizeGroupMode  mode,
+                                  gint              for_size,
+                                 gint             *minimum,
+                                 gint             *natural)
 {
   GSList *widgets;
   GSList *tmp_list;
   gint    min_result = 0, nat_result = 0;
 
+  if (!_gtk_widget_get_sizegroups (widget))
+    return;
+
   widgets = widget_get_size_group_peers (widget, mode);
 
   g_slist_foreach (widgets, (GFunc)g_object_ref, NULL);
@@ -654,20 +673,7 @@ compute_dimension (GtkWidget        *widget,
         }
       else
         {
-          if (mode == GTK_SIZE_GROUP_HORIZONTAL)
-            {
-              if (for_size < 0)
-                gtk_widget_get_preferred_width (tmp_widget, &min_dimension, &nat_dimension);
-              else
-                gtk_widget_get_preferred_width_for_height (tmp_widget, for_size, &min_dimension, &nat_dimension);
-            }
-          else
-            {
-              if (for_size < 0)
-                gtk_widget_get_preferred_height (tmp_widget, &min_dimension, &nat_dimension);
-              else
-                gtk_widget_get_preferred_height_for_width (tmp_widget, for_size, &min_dimension, &nat_dimension);
-            }
+          _gtk_widget_compute_size_for_orientation (tmp_widget, mode, TRUE, for_size, &min_dimension, &nat_dimension);
         }
 
       min_result = MAX (min_result, min_dimension);
@@ -682,43 +688,6 @@ compute_dimension (GtkWidget        *widget,
   *natural = nat_result;
 }
 
-/**
- * _gtk_size_group_bump_requisition:
- * @widget: a #GtkWidget
- * @mode: either %GTK_SIZE_GROUP_HORIZONTAL or %GTK_SIZE_GROUP_VERTICAL, depending
- *        on the dimension in which to bump the size.
- * @for_size: Size to request minimum and natural size for
- * @minimum: a pointer to the widget's minimum size
- * @natural: a pointer to the widget's natural size
- *
- * Refreshes the sizegroup while returning the groups requested
- * value in the dimension @mode.
- *
- * This function is used both to update sizegroup minimum and natural size 
- * information and widget minimum and natural sizes in multiple passes from 
- * the size request apis.
- */
-void
-_gtk_size_group_bump_requisition (GtkWidget        *widget,
-                                 GtkSizeGroupMode  mode,
-                                  gint              for_size,
-                                 gint             *minimum,
-                                 gint             *natural)
-{
-  if (!_gtk_widget_get_sizegroup_bumping (widget))
-    {
-      /* Avoid recursion here */
-      _gtk_widget_set_sizegroup_bumping (widget, TRUE);
-
-      if (_gtk_widget_get_sizegroups (widget))
-       compute_dimension (widget, mode, for_size, minimum, natural);
-
-      _gtk_widget_set_sizegroup_bumping (widget, FALSE);
-    }
-}
-
-
-
 /**
  * _gtk_size_group_queue_resize:
  * @widget: a #GtkWidget
index 2f4dc0871cfbaa6c5c25f02513b5247a1ccd3e70..73b8da3859dd3226a303164e71ffd973d8d28ca8 100644 (file)
@@ -357,7 +357,6 @@ struct _GtkWidgetPrivate
 
   /* SizeGroup related flags */
   guint sizegroup_visited     : 1;
-  guint sizegroup_bumping     : 1;
   guint have_size_groups      : 1;
 
   /* The widget's name. If the widget does not have a name
@@ -13831,19 +13830,6 @@ _gtk_widget_set_sizegroup_visited (GtkWidget    *widget,
   widget->priv->sizegroup_visited = visited;
 }
 
-gboolean
-_gtk_widget_get_sizegroup_bumping (GtkWidget    *widget)
-{
-  return widget->priv->sizegroup_bumping;
-}
-
-void
-_gtk_widget_set_sizegroup_bumping (GtkWidget    *widget,
-                                  gboolean      bumping)
-{
-  widget->priv->sizegroup_bumping = bumping;
-}
-
 void
 _gtk_widget_add_sizegroup (GtkWidget    *widget,
                           gpointer      group)
index a568ed020b41b6aeeadafdf0e6f9bd2bd4bcb816..4ee04e33cdcf3f0919d07d93de58c0e1bdaaacd5 100644 (file)
@@ -90,9 +90,6 @@ void         _gtk_widget_set_height_request_needed (GtkWidget *widget,
 gboolean     _gtk_widget_get_sizegroup_visited (GtkWidget    *widget);
 void         _gtk_widget_set_sizegroup_visited (GtkWidget    *widget,
                                                gboolean      visited);
-gboolean     _gtk_widget_get_sizegroup_bumping (GtkWidget    *widget);
-void         _gtk_widget_set_sizegroup_bumping (GtkWidget    *widget,
-                                               gboolean      bumping);
 void         _gtk_widget_add_sizegroup         (GtkWidget    *widget,
                                                gpointer      group);
 void         _gtk_widget_remove_sizegroup      (GtkWidget    *widget,